#include <reg52.h>
#include "keyscan.h"
#include "tube.h"

void sendData(uchar num_1, uchar num_2, uchar num_3, uchar num_4){
	
}

void main() {
	char key_temp = -1;
	uchar digit = 1, num_left_end = 10, num_middle_left = 10, num_middle_right = 10, num_right_end = 10;
	while (1) { // ?????
		if(getKey()>=0) key_temp = getKey();
		if(key_temp == 0x0E){
			num_left_end = 10;
			num_middle_left = 10;
			num_middle_right = 10;
			num_right_end = 10;
			digit = 1;
		}
		else if(key_temp == 0x0F){
//			sendData();
		}
		else if(key_temp == 0x0A){
			num_left_end = 10;
			digit = 1;
		}
		else if(key_temp == 0x0B){
			num_middle_left = 10;
			digit = 2;
		}
		else if(key_temp == 0x0C){
			num_middle_right = 10;
			digit = 3;
		}
		else if(key_temp == 0x0D){
			num_right_end = 10;
			digit = 4;
		}
		else if(key_temp >= 0 && key_temp <= 9){
				switch(digit){
					case 1:{
						num_left_end = key_temp;
						break;
					}
					case 2:{
						num_middle_left = key_temp;
						break;
					}
					case 3:{
						num_middle_right = key_temp;
						break;
					}
					case 4:{
						num_right_end = key_temp;
						break;
					}
				}
			}
			tube_display(num_left_end,num_middle_left,num_middle_right,num_right_end,4);
		}
	}